package com.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.OwnersMapper;
import com.mapper.ParkingcarMapper;
import com.pojo.Owners;
import com.service.OwnersService;
import com.vo.OwnersVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OwnersServiceimpl implements OwnersService {
    @Resource
   private OwnersMapper ownersMapper;

    @Resource
    private ParkingcarMapper parkingcarMapper;
    @Override
    public int selectbyname1(String name) {
        int count = ownersMapper.selectbyname1(name);
        return count;
    }

    @Override
    public int selectbyname(String name) {
        int count = ownersMapper.selectbyname(name);
        return count;
    }

    @Override
    public String selectphonebyname(Integer ownerid) {
        String selectphonebyname = ownersMapper.selectphonebyname(ownerid);
        return selectphonebyname;
    }

    @Override
    public int insertSelective(Owners record) {
        int i = ownersMapper.insertSelective(record);
        return i;
    }

    @Override
    public Owners selectownerBycardno(String cardno) {
        Owners owners = ownersMapper.selectownerBycardno(cardno);
        return owners;
    }

    @Override
    public int updateIsnoBycardno(int id, int isno) {
        int i = ownersMapper.updateIsnoBycardno(id, isno);
        return i;
    }

    @Override
    public PageInfo<Owners> selectownerall(OwnersVo ownersVo) {
        PageHelper.startPage(ownersVo.getPage(),ownersVo.getLimit());
        List<Owners> selectownerall = ownersMapper.selectownerall(ownersVo);
        PageInfo<Owners> pageInfo=new PageInfo<>(selectownerall);
        return pageInfo;
    }

    @Override
    public Owners selectidByphone(String phone) {
        Owners owners = ownersMapper.selectidByphone(phone);
        return owners;
    }
    @Override
    public Owners selectOwnersByName(String ownername) {
        Owners owners = ownersMapper.selectOwnerByName(ownername);
        return owners;
    }

    @Override
    public Owners selectOwnerById(Integer id) {
        Owners owners = ownersMapper.selectOwnerById(id);
        return owners;
    }

    @Override
    public int selecttotalownerByplotid(Integer plotid) {
        int i = ownersMapper.selecttotalownerByplotid(plotid);
        return i;
    }

    @Override
    public Owners selectOwnerByPhone(String phone) {
        Owners owners = ownersMapper.selectOwnerByPhone(phone);
        return owners;
    }

    @Override
    public List<Owners> selectAllOwner() {
        List<Owners> owners = ownersMapper.selectAllOwner();
        return owners;
    }

    @Override
    public List<Owners> selectOwnerHaveCar() {
        List<Integer> list = parkingcarMapper.selectowneridHaveCar();
        List<Owners> owners = ownersMapper.selectOwnerHaveCar(list);
        return owners;
    }

    @Override
    public List<Integer> selectidbyownername(String name) {
       List<Integer> selectidbyownername = ownersMapper.selectidbyownername(name);
        return selectidbyownername;
    }
}
